From 5706ebdbbeac34eb05f59b1370c776cec140e794 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 7 Sep 2014 16:01:55 -0700 Subject: [PATCH] Mention the name of a package in a custom build failure Closes #530 --- src/cargo/ops/cargo_rustc/mod.rs | 7 ++++++- tests/test_cargo_compile.rs | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index f9cb09631..e56ae4b31 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -182,6 +182,7 @@ fn compile_custom(pkg: &Package, cmd: &str, p = p.env(format!("DEP_{}_OUT_DIR", name).as_slice(), Some(&layout.native(pkg))); } + let pkg = pkg.to_string(); Ok(proc() { if first { @@ -193,7 +194,11 @@ fn compile_custom(pkg: &Package, cmd: &str, internal("failed to create output directory for build command") })); } - try!(p.exec_with_output().map(|_| ()).map_err(|e| e.mark_human())); + try!(p.exec_with_output().map(|_| ()).map_err(|mut e| { + e.msg = format!("Failed to run custom build command for `{}`\n{}", + pkg, e.msg); + e.mark_human() + })); Ok(()) }) } diff --git a/tests/test_cargo_compile.rs b/tests/test_cargo_compile.rs index 9c754cc34..2e16fca23 100644 --- a/tests/test_cargo_compile.rs +++ b/tests/test_cargo_compile.rs @@ -691,11 +691,13 @@ test!(custom_build_failure { "#); assert_that(p.cargo_process("build"), execs().with_status(101).with_stderr(format!("\ +Failed to run custom build command for `foo v0.5.0 ({dir}) Process didn't exit successfully: `{}` (status=101)\n\ --- stderr\n\ task '
' failed at 'nope', {filename}:2\n\ \n\ -", build.bin("foo").display(), filename = format!("src{}foo.rs", path::SEP)))); +", build.bin("foo").display(), filename = format!("src{}foo.rs", path::SEP), + dir = p.url()))); }) test!(custom_second_build_failure { @@ -752,11 +754,13 @@ test!(custom_second_build_failure { "#); assert_that(p.cargo_process("build"), execs().with_status(101).with_stderr(format!("\ +Failed to run custom build command for `foo v0.5.0 ({dir}) Process didn't exit successfully: `{}` (status=101)\n\ --- stderr\n\ task '
' failed at 'nope', {filename}:2\n\ \n\ -", build2.bin("bar").display(), filename = format!("src{}bar.rs", path::SEP)))); +", build2.bin("bar").display(), filename = format!("src{}bar.rs", path::SEP), + dir = p.url()))); }) test!(custom_build_env_vars { -- 2.30.2